package com.mzkj.wanjulaile.mobile.api.modules.activeConfig.service;

import com.mzkj.wanjulaile.mobile.api.modules.activeConfig.constant.ActiveConstant;
import com.mzkj.wanjulaile.mobile.api.modules.activeConfig.entity.ActiveShareConfig;
import com.mzkj.wanjulaile.mobile.api.modules.activeConfig.entity.ActiveShareCoupon;
import com.mzkj.wanjulaile.mobile.api.modules.activeConfig.mapper.ActiveShareConfigMapper;
import com.mzkj.wanjulaile.mobile.api.modules.activeConfig.mapper.ActiveShareCouponMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分享活动配置Service
 *
 * @author ianly
 * @version 2017-02-08
 */
@Service
public class ActiveShareConfigServiceImpl implements ActiveShareConfigService{

    @Autowired
    private ActiveShareCouponMapper activeShareCouponDao;

    @Autowired
    private ActiveShareConfigMapper activeShareConfigMapper;

    public ActiveShareConfig get(String id) {
        ActiveShareConfig activeShareConfig = activeShareConfigMapper.get(id);
        activeShareConfig.setActiveSharerCouponList(activeShareCouponDao.findList(new ActiveShareCoupon(activeShareConfig, ActiveConstant.SHARER_PERSON)));
        activeShareConfig.setActiveSharedCouponList(activeShareCouponDao.findList(new ActiveShareCoupon(activeShareConfig,ActiveConstant.SHARED_PERSON)));
        return activeShareConfig;
    }

    @Override
    public List<ActiveShareConfig> findList(ActiveShareConfig activeShareConfig) {
        return activeShareConfigMapper.findList(activeShareConfig);
    }
}